'use strict';

/* 加载：公共组件插件 */
var React = require("react"),
    Router = require("react-router"),
    RouteHandler = Router.RouteHandler,
    Route = Router.Route,
    DefaultRoute = Router.DefaultRoute,
    NotFoundRoute = Router.NotFoundRoute;


/* 加载：页面组件 */
var LoginModule = require("./module/LoginModule"),                        // 登录页
    IndexModule = require("./module/IndexModule"),
    ReportModule = require("./module/ReportModule"),
    UserModule = require("./module/UserModule"),
    NotFoundModule = require("./module/NotFoundModule");                  // 404页


/* 设置路由 */
var routes_for_master = (
    <Route handler={app} path="/">
        <Route name="login" handler={LoginModule} path="login"></Route>
        <Route name="index" handler={IndexModule} path="index"></Route>
        <Route name="order" handler={IndexModule} path="order"></Route>
        <Route name="user" handler={UserModule} path="user"></Route>
        <Route name="report" handler={ReportModule} path="report"></Route>

        <DefaultRoute name="home" handler={LoginModule}></DefaultRoute>

        <NotFoundRoute name="missing" handler={NotFoundModule}/>
    </Route>
);


/* 创建页面应用 */
var app = React.createClass({
    render: function () {
        return (<RouteHandler />)
    }
});


/* 页面应用监听路由规则 */
Router.run(routes_for_master, function (Handler) {
    React.render(<Handler />, document.getElementById("app"));
});
